def sanx():
    global r,x,y,o,g,t,h,t,m,cuowu,cuo
    import time,random
    r = 0
    x = 0
    y = 0
    o = 0
    g = 6   #告诉程序一共听写几次
    m = 0
    cuo = 0
    t = {}
    h = {}
    t = {}
    cuowu = {}
    yi = {'UK':'英国','Canada':'加拿大','USA':'美国','China':'中国','she':'她；（指雌性动物）它','student':'学生, 学者','pupil':'小学生','he':'他；它（指雄性动物）','teacher':'教师, 老师, 导师','boy':'男孩, 儿子, 孩子气的人, 男仆','and':'和','girl':'女孩, 少女, 女仆, (商店等的)女工作人员','new':'新的，新近的；新来的；不熟悉的','friend':'朋友，友人；支持者，同情者','today':'今天；现在，目前'}
    er = {'father':'父亲；爸爸','dad':'（口语）爸爸；爹爹','man':'男人','woman':'女人','mother':'母亲；妈妈','sister':'姐；妹','brother':'兄；弟','grandmother':'（外）祖母','grandma':'（口语）（外）祖母','grandfather':'（外）祖父','grandpa':'（口语）（外）祖父','family':'家；家庭'}
    san = {'thin':'瘦的','fat':'胖的；肥的','tall':'高的','short':'矮的；短的','long':'长的','small':'小的','big':'大的','giraffe':'长颈鹿','so':'这么；那么 ','children':'儿童（child的复数形式）','child':'儿童','tail':'尾巴'}
    si = {'on':'在……上','in':'在……里','under':'在……下面','chair':'椅子','desk':'书桌','cap':'帽子','ball':'球','car':'小汽车','boat':'小船','map':'地图','toy':'玩具','box':'盒；箱'}
    wu = {'pear':'梨','apple':'苹果','orange':'橙子','banana':'香蕉','watermelon':'西瓜','strawberry':'草莓','grape':'葡萄','buy':'买','fruit':'水果'}
    liu = {'eleven':'十一','twelve':'十二','thirteen':'十三','fourteen':'十四','fifteen':'十五','sixteen':'十六','seventeen':'十七','eighteen':'十八','nineteen':'十九','twenty':'二十','kite':'风筝','beautiful':'美丽的'}
    e = {0:yi,1:er,2:san,3:si,4:wu,5:liu}
    def q(v):
        global r,x,y,o,g,t,h,t,m,cuowu,cuo
        dict_key_ls = list(v.keys())
        random.shuffle(dict_key_ls)
        new_dic = {}
        for key in dict_key_ls:
            new_dic[key] = v.get(key)
        v = new_dic
        for i in v:
            cuowu = v[i]
            q = input(cuowu + '：')
            w = i
            if q == w:
                print('对喽！')
                r += 1
            else:
                print('错啦错啦！')
                t[cuowu] = w
                x += 1
        print('结束！')
        print('一共对',r,'道，错',x,'道')
        if x != 0:
            cuo += 1
            print('\n不扎实',x,'道！巩固错题：')
            x = 0
            for i in t:
                if i == "讲台":
                    q = input(i + "：")
                    w = i 
                else:
                    q = input(i + '：')
                    w = i
                w = t[i]
                if q == w:
                    print('对喽！')
                    y += 1
                else:
                    print('错啦错啦！')
                    o += 1
                    m += 1
                    x += 1
                    h[i] = w
            print('结束！')
            print('一共对',y,'道，错',o,'道')
        r = 0
        c = 0
        y = 0
        o = 0
        x = 0
        t = {}
    for l in range(g):
        print('\n第',l+1,'单元！\n')
        v = e[l]
        q(v)
    if m != 0:
        html = open('cuowu.txt','r')
        php = html.read()
        html.close()
        go = open('cuowu.txt','a')
        print('\n错题答案：共',m,'个二错单词\n')
        for i in h:
            d = h[i]
            print(i , d)
            if i not in php or d not in php:
                go.write("'")
                go.write(i)
                go.write("'")
                go.write(':')
                go.write("'")
                go.write(d)
                go.write("'")
                go.write(',\n')
        go.close()
    time.sleep(10)